package com.vogue.supplymall.order.domain.mapper;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Lang;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import com.vogue.ssm.database.util.SqlLangDriver;
import com.vogue.supplymall.order.domain.model.Order;
import com.vogue.supplymall.order.domain.provider.OrderPullSqlProvider;

@Mapper
public interface OrderPullMapper extends BaseMapper<Order, Long>{

	/**
	 * 查询指定企业的作为卖家的订单
	 * @param syscodeid
	 * @param maxdate
	 * @return
	 */
	@SelectProvider(type = OrderPullSqlProvider.class, method = "pullSell")
	public List<Map<String, Object>> pullSell(Long syscodeid, Date maxdate) throws RuntimeException;

	/**
	 * 查询指定企业的作为买家的订单
	 * @param syscodeid
	 * @param maxdate
	 * @return
	 */
	@SelectProvider(type = OrderPullSqlProvider.class, method = "pullBuy")
	public List<Map<String, Object>> pullBuy(Long syscodeid, Date maxdate) throws RuntimeException;
	
	/**
	 * 根据syscodeid和订单号，查询订单号
	 */
	@Select("select ordernumber from `order` where syscodeid=#{arg0} and ordernumber in (#{arg1}) and ordernumber not in (#{arg2})")
	@Lang(SqlLangDriver.class)
	public List<String> findOrdernumbers(Long syscodeId,List<String> orderNums,List<String> repeatIds);
	
	/**
	 * 获取卖家拉取订单的总数
	 * @param syscodeid
	 * @param maxdate
	 * @return
	 * @throws RuntimeException
	 */
	@SelectProvider(type = OrderPullSqlProvider.class, method = "pullSellCount")
	public Map<String, Object> pullSellCount(Long syscodeid, Date maxdate) throws RuntimeException;
	
	/**
	 * 获取买家拉取订单的总数
	 * @param syscodeid
	 * @param maxdate
	 * @return
	 * @throws RuntimeException
	 */
	@SelectProvider(type = OrderPullSqlProvider.class, method = "pullBuyCount")
	public Map<String, Object> pullBuyCount(Long syscodeid, Date maxdate) throws RuntimeException;

	/**
	 * 获取卖家拉取退货订单的总数
	 * @param syscodeid
	 * @param maxdate
	 * @return
	 * @throws RuntimeException
	 */
	@SelectProvider(type = OrderPullSqlProvider.class, method = "pullRefundSellCount")
	public Map<String, Object> pullRefundSellCount(Long syscodeid, Date maxdate) throws RuntimeException;

	/**
	 * 查询指定企业的作为卖家的退货订单
	 * @param syscodeid
	 * @param maxdate
	 * @return
	 */
	@SelectProvider(type = OrderPullSqlProvider.class, method = "pullRefundSell")
    public List<Map<String, Object>> pullRefundSell(Long syscodeid, Date maxdate) throws RuntimeException;
}
